$(function () {
    $("#btnlogin").click(function () {
        var username = $("#name").val();
        var password = $("#pass").val();
        $.ajax({
            url: '/sign_in',
            dataType: "json",
            type: "post",
            async: true,
            data: {username: username, password: password},
            success: function (data) {
                if (data.code == "0") {
                    alert('管理员登陆成功!');
                    window.location.href = 'adminManagement.html';
                } else if (data.code == "1") {
                    alert('用户登陆成功!');
                    window.location.href = 'index.html';
                } else {
                    alert('用户名或密码错误！');
                }
            },
            error: function (error) {
                console.log(error);
                $.alert("登录请求错误！");
            }
        });
        /*阻止form提交*/
        return false;
    })
})

